package com.monolithiot.sso.common.vo;

import lombok.Data;

import java.util.List;

/**
 * 2018/12/3 Create by 郭文梁
 * LayTableResponse
 * LayUI 表格要求的数据格式
 *
 * @author 郭文梁
 * @date 2018/12/3
 */
@Data
public class LayTableResponse<T> {
    private static final Integer CODE_OK = 0;

    /**
     * 静态工厂方法
     *
     * @param data  数据
     * @param count 记录总数
     * @param <T>   数据类型
     * @return LayTableResponse
     */
    public static <T> LayTableResponse<T> of(List<T> data, Long count) {
        LayTableResponse<T> res = new LayTableResponse<>();
        res.code = CODE_OK;
        res.count = count;
        res.data = data;
        return res;
    }

    private Integer code;
    private Long count;
    private List<T> data;
    private String msg;

    /**
     * 设置返回信息
     *
     * @param msg 返回信息
     * @return this
     */
    public LayTableResponse<T> msg(String msg) {
        this.msg = msg;
        return this;
    }
}
